import java.util.Scanner;

class Solution {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
//        System.out.println("请输入人数");
//        int n = scanner.nextInt();
//        System.out.println("请输入行数：");
//        int row = scanner.nextInt();
//        System.out.println("请输入列数");
//        int col = scanner.nextInt();
//        int[][] trust = new int[row][col];
//        for (int i = 0; i < row; i++) {
//            for (int j = 0; j < col; j++) {
//                int m = scanner.nextInt();
//            }
//        }
        int[][] trust = new int[2][2];
        for (int i = 1; i < 3; i++) {
            for (int j = 0; j < 2; j++) {
                int m = scanner.nextInt();
            }
        }
        int Judge = findJudge(3,trust);
        System.out.println(Judge);
    }

    public static int findJudge(int n, int[][] trust) {
        //新建一个数组存放事件
        int[] li = new int[n+1];
        for(int[] people : trust){
            //有信任的人就是负数
            li[people[0]]--;
            //被信任就+1
            li[people[1]]++;
        }
        for(int i = 1; i < li.length;i++){
            if(li[i] == n-1){
                return i;
            }
        }
        return -1;
    }
}


